#include <util.h>
#include <sysregs.h>
#include <arch/page_tables.h>

    .macro reserved_region _pa, _size_in_gb
        .rept   \_size_in_gb
        .8byte  0
        .set    \_pa, \_pa + L1_BLOCK_SIZE
        .endr
    .endm

    .macro map_region_flat _pa, _size_in_gb, _attr
        .rept   \_size_in_gb
        .8byte  (PTE_SUPERPAGE | \_attr) + \_pa
        .set    \_pa, \_pa + L1_BLOCK_SIZE
        .endr
    .endm

 .section .page_tables, "aw"
 .balign PAGE_SIZE
l1_page_table:
    .set ADDR, 0

    map_region_flat ADDR 1 _attr=(MT_DEVICE | MT_SECURE)
    map_region_flat ADDR 1 _attr=(MT_MEMORY | MT_SECURE)
    map_region_flat ADDR 1 _attr=(MT_NON_CACHEABLE | MT_SECURE)
    map_region_flat ADDR 1 _attr=(MT_NON_CACHEABLE | MT_NS)
    reserved_region ADDR 1

.balign PAGE_SIZE
.global root_page_table
root_page_table:
    .8byte (PTE_TABLE) + l1_page_table
    .balign PAGE_SIZE
